skip list

Hello Everyone,

Is it possible to insert a current object to a skip list ??

I do not want to insert the value of the attribut like obj."attribut" but the obj current itself.

What i usually did is entering the abso number, and thru the abso number, i get the object then any attribut I want, but this time there is no abso number attribut in my module, so i can not do :

string abso_1=(key skBaseline) string
obj_v1=object(intOf(abso_1),b2)
izzo - Mon Mar 28 10:01:49 EDT 2011

Re: skip list
llandale - Mon Mar 28 14:52:42 EDT 2011

You can put an "Object" handle into a skip list yes. Consider the following that prints the objects in absolute number order:

Skip  skpObjects = create  // KEY: 'int' AbsNo; DATA: 'Object' Handle
int   AbsNo
Object obj
for obj in entire (current Module) do
{  AbsNo = obj."Absolute Number"
   put (skpObjects, AbsNo, obj)
}
for obj in skpObjects do
{  AbsNo = (int key skpObjects)
   print AbsNo "\t" number(obj) "\t" obj."MyTestAttr" "\n"
}
delete(skpObjects)


Objects are retrieved (the 2nd loop) in sorted order based on Key, in this case the Absolute Number.

You can put data structures into a Skip list as data, such as subordinate Skip Lists. I've done that recently in a module where I have created my own identifiers and want to find those that are duplicates. Plow through the module, get the ID, stick the ID and a sub-Skip in the Main skip, adding this object to the sub-skip. This is sticky for beginners; don't forget to delete all the sub-Skips before the main skip.

 

 

  • Louie

 

 

Re: skip list
bullbala - Tue Mar 29 02:06:20 EDT 2011

llandale - Mon Mar 28 14:52:42 EDT 2011

You can put an "Object" handle into a skip list yes. Consider the following that prints the objects in absolute number order:

Skip  skpObjects = create  // KEY: 'int' AbsNo; DATA: 'Object' Handle
int   AbsNo
Object obj
for obj in entire (current Module) do
{  AbsNo = obj."Absolute Number"
   put (skpObjects, AbsNo, obj)
}
for obj in skpObjects do
{  AbsNo = (int key skpObjects)
   print AbsNo "\t" number(obj) "\t" obj."MyTestAttr" "\n"
}
delete(skpObjects)


Objects are retrieved (the 2nd loop) in sorted order based on Key, in this case the Absolute Number.

You can put data structures into a Skip list as data, such as subordinate Skip Lists. I've done that recently in a module where I have created my own identifiers and want to find those that are duplicates. Plow through the module, get the ID, stick the ID and a sub-Skip in the Main skip, adding this object to the sub-skip. This is sticky for beginners; don't forget to delete all the sub-Skips before the main skip.

 

 

  • Louie

 

 

Hi Louie,

Out of curiosity, for your recent need to find duplicates in your own identifiers, is it mandatory to use to more than one Skip ?

Is it possible to find duplicates in your identifiers using only one skip as in the following script (this example uses the standard identifiers instead)?
 

Object o
Skip uniqueIDs = createString()
 
filtering off
 
string objIdentifier = null
int count = 0
 
for o in current Module do
{
    objIdentifier = identifier o
        
        if(put(uniqueIDs, objIdentifier, 1) == false)
        {
                find(uniqueIDs, objIdentifier, count)
                count++
                delete(uniqueIDs, objIdentifier)
                put(uniqueIDs, objIdentifier, count)
        }
}
 
for count in uniqueIDs do
{
        if(count > 1)
        {
                // must cast the key command.
                objIdentifier = (string key uniqueIDs)
                
                print "Found " (count) " objects with Identifier " objIdentifier ".\n"
        }
}
 
delete uniqueIDs

Re: skip list
izzo - Tue Mar 29 05:25:39 EDT 2011

llandale - Mon Mar 28 14:52:42 EDT 2011

You can put an "Object" handle into a skip list yes. Consider the following that prints the objects in absolute number order:

Skip  skpObjects = create  // KEY: 'int' AbsNo; DATA: 'Object' Handle
int   AbsNo
Object obj
for obj in entire (current Module) do
{  AbsNo = obj."Absolute Number"
   put (skpObjects, AbsNo, obj)
}
for obj in skpObjects do
{  AbsNo = (int key skpObjects)
   print AbsNo "\t" number(obj) "\t" obj."MyTestAttr" "\n"
}
delete(skpObjects)


Objects are retrieved (the 2nd loop) in sorted order based on Key, in this case the Absolute Number.

You can put data structures into a Skip list as data, such as subordinate Skip Lists. I've done that recently in a module where I have created my own identifiers and want to find those that are duplicates. Plow through the module, get the ID, stick the ID and a sub-Skip in the Main skip, adding this object to the sub-skip. This is sticky for beginners; don't forget to delete all the sub-Skips before the main skip.

 

 

  • Louie

 

 

Yes , you are tottaly right !

Thanks

Re: skip list
llandale - Tue Mar 29 16:21:16 EDT 2011

bullbala - Tue Mar 29 02:06:20 EDT 2011

Hi Louie,

Out of curiosity, for your recent need to find duplicates in your own identifiers, is it mandatory to use to more than one Skip ?

Is it possible to find duplicates in your identifiers using only one skip as in the following script (this example uses the standard identifiers instead)?
 

Object o
Skip uniqueIDs = createString()
 
filtering off
 
string objIdentifier = null
int count = 0
 
for o in current Module do
{
    objIdentifier = identifier o
        
        if(put(uniqueIDs, objIdentifier, 1) == false)
        {
                find(uniqueIDs, objIdentifier, count)
                count++
                delete(uniqueIDs, objIdentifier)
                put(uniqueIDs, objIdentifier, count)
        }
}
 
for count in uniqueIDs do
{
        if(count > 1)
        {
                // must cast the key command.
                objIdentifier = (string key uniqueIDs)
                
                print "Found " (count) " objects with Identifier " objIdentifier ".\n"
        }
}
 
delete uniqueIDs

First off, every <identifier(o)> in your module is in fact different so your script as written will NEVER survive your first <if> statement and count will never be incremented. OK, without module corruption.

But lets suppose that you change <identifier o> to <o."ProcedureNumber">. Your script will adequately COUNT the number of objects that have that same Procedure OK and summarize the non-unique Procedures. What I wanted was to list each such object; so captured each object with that Procedure, and in the final loop print the Procedure Number used by more than one object, but also list the information about each such object, no doubt <identifier o> but perhaps also <number(o)>.

Found 3 objects with ProcedureNumber 'ABC001':
    MyMod_32    3.2.1-0.2
        MyMod_455       3.5.1-0.1
        MyMod_129       3.5.1.5-0.4


To do that I chose to create a sub-Skip list for each Procedure number; but could have done it with a flat structure that I would clumsily search through order-X times for each Procedure; effectively searching the entire module completely once for each different Procedure.

 

 

  • Louie

 

 

Re: skip list
bullbala - Wed Mar 30 02:45:45 EDT 2011

llandale - Tue Mar 29 16:21:16 EDT 2011

First off, every <identifier(o)> in your module is in fact different so your script as written will NEVER survive your first <if> statement and count will never be incremented. OK, without module corruption.

But lets suppose that you change <identifier o> to <o."ProcedureNumber">. Your script will adequately COUNT the number of objects that have that same Procedure OK and summarize the non-unique Procedures. What I wanted was to list each such object; so captured each object with that Procedure, and in the final loop print the Procedure Number used by more than one object, but also list the information about each such object, no doubt <identifier o> but perhaps also <number(o)>.

Found 3 objects with ProcedureNumber 'ABC001':
    MyMod_32    3.2.1-0.2
        MyMod_455       3.5.1-0.1
        MyMod_129       3.5.1.5-0.4


To do that I chose to create a sub-Skip list for each Procedure number; but could have done it with a flat structure that I would clumsily search through order-X times for each Procedure; effectively searching the entire module completely once for each different Procedure.

 

 

  • Louie

 

 

I understand the issue better now, Louie.
Merci !

Re: skip list
izzo - Wed Mar 30 08:33:52 EDT 2011

bullbala - Wed Mar 30 02:45:45 EDT 2011
I understand the issue better now, Louie.
Merci !

Mais de rien !!!
Are you a frenchie?